<template>
    <div id="all">
        <nav>
            <span class="fa fa-angle-left" @touchstart="back"></span>
            <span>{{info}}</span>
            <router-link to="/second/ShoppingCar">
                <span class="fa fa-shopping-cart"></span>
            </router-link>
        </nav>
        <div id="top">
            <span>区域<span class="fa fa-angle-down"></span></span>
            <span>分类<span class="fa fa-angle-down"></span></span>
            <span @touchstart="show=!show">排序<span class="fa fa-angle-down" v-show="show" @touchstart="sort"></span><span class="fa fa-angle-up" v-show="!show" @touchstart="sort"></span></span>
        </div>
        <div id="content">
            <div v-for="s in arr" class="all" >
                <router-link :to="'/Kind/GoodList/Detail/'+s.name">
                <div class="list">
                    <div class="left">
                        <img :src="s.picture[1]">
                    </div>
                    <div class="right">
                        <span>双11</span>
                        <span>{{s.name}}</span>
                        <p>包邮</p>
                        <p>￥{{s.price}}</p>
                        <p>800人已付款</p>
                        <p>{{s.area}}</p>
                    </div>
                </div>
                </router-link>
            </div>
        </div>
    </div>
</template>

<script>
export default{
    data:function(){
        return{
            info:"",
            arr:[],
            show:true,
            a:1
        }
    },
    mounted:function(){
        this.info = this.name;
        this.list();
    },
    computed:{
        name:function(){
            return this.$route.params.qwe;
        }
    },
    methods:{
        back:function(){
            history.back();
        },
        list:function(){
            var params = {
                name:this.name
            }
            this.$store.dispatch("requestList",params)
            .then(res=>{
                this.arr = res.data.msg;
            })
        },
        sort:function(){
            if(show==true){
                var o = {
                    a:!this.a,
                    name:this.info
                }
                this.$store.dispatch("requestSort",o)
                .then(res=>{
                    this.arr = res.data.msg;
                })
            }else{
                var o = {
                    a:this.a,
                    name:this.info
                }
                this.$store.dispatch("requestSort",o)
                .then(res=>{
                    this.arr = res.data.msg;
                })
            }
        },
    },

}
</script>

<style scoped>
    #all{
        height:100vh;
        background:white;
    }
    nav{
        height: 35px;
        border-bottom: 1px solid #999;
        line-height: 35px;
        display: flex;
        justify-content: space-between;
        padding: 0 8px;
        background-color: orangered;
        color: white;
    }
    .fa-angle-left{
        font-size: 20px;
        margin-top: 6px;
    }
    .fa-shopping-cart{
        font-size: 20px;
        color: white;
    }
    #top{
        display: flex;
        justify-content: space-between;
        padding: 0 8px;
        border-bottom: 1px solid #ccc;
        height: 35px;
        line-height: 35px;
    }
    #conent{
        height: calc(100vh - 35px);
        overflow-y: scroll;
    }
    #hide{
        position: absolute;
        right: 5px;
        top: 1px;
        
    }
    .fa-caret-up{
        font-size: 25px;
        position: relative;
        top: 9px;
        left: 79px;
        color: rgba(0,0,0,0.75);
    }
    #hide-bottom{
        width: 100px;
        height: 70px;
        border: 1px solid #666;
        color: white;
        background-color: rgba(0,0,0,0.75);
    }
    .one{
        border-bottom: 1px solid #999;
    }
    .two,.one{
        height: 35px;
        line-height: 35px; 
        padding-left: 8px;
    }
    .one span:nth-of-type(2){
        margin-left: 6px;
        font-size: 14px;
    }
    .two span:nth-of-type(2){
        margin-left: 6px;
        font-size: 14px;
    }
    .all a{
        color: black;
        text-decoration: none;
    }
    .all{
        margin-top: 8px;
    }
    .list{
        display: flex;
        padding: 0 0 2px 0;
        border-bottom: 1px solid #eee;
    }
    .left img{
        width: 110px;
        height: 110px;
    }
    .right{
        margin-left: 8px;
    }
    .right span:nth-of-type(1){
        font-size: 12px;
        display: inline-block;
        padding: 0 2px;
        background-color: red;
        color: white;
        border-radius: 3px;
    }
    .right p{
        margin: 0;
    }
    .right p:nth-of-type(1){
        margin-top: 10px;
        font-size: 13px;
        width: 30px;
        border: 1px solid orange;
        color: orange;
    }
    .right p:nth-of-type(2){
        margin-top: 10px;
        display: inline-block;
    }
    .right p:nth-of-type(3){
        display: inline-block;
        margin-left: 15px;
        font-size: 14px;
        color: #999;
    }
    .right p:nth-of-type(4){
        margin-top: 8px;
        font-size: 14px;
    }
</style>